var ProductDia={
	
	/*获取分页数据*/
	getPageableData:function(model,callback){
		//重新更新store
		model.test.refreshStore();
		
		//获取传递参数初使化查询条件
		var conditionSql={
			Shape:'',
			Color:'',
			Clarity:'',
			Certificate:'',
			Cut:'',
			Fluorescence:'',
			Polishing:'',
			Placebelong:'',
			Symmetric:'',
			Spotorno:'',
			Currency:'',
			WeightStart:'',
			WeightEnd:'',
			CurrencyStart:'',
			CurrencyEnd:''
		};
		$.each(conditionSql, function(key,val) {
			conditionSql[key]=model.state[lowerFirstLetter(key)];
		});
		conditionSql=_.omit(conditionSql,function(val,key,obj){
			return val==null || val=='';
		});
		
		//遍历条件，移除不符合数组项
		var data=[];
		var dataAll=model.test.store.findAll();
		if(_.isEmpty(conditionSql))
		{
			data=dataAll;
		}else{
			var dataCollection=dataAll;
			$.each(conditionSql,function(key,val){
				data=[];
				$.each(val.split('_'), function(i,value) {
					var condtion={};
					condtion[key]=value;
					
					dataTmp=_.where(dataCollection,condtion);
					$.each(dataTmp,function(j,obj){
						data.includes(obj) || data.push(obj);
					});
					
				});
				dataTmp=data;
				dataCollection=data;
			});
		}
		//var data=_.isEmpty(conditionSql) ? model.test.store.findAll() : _.where(model.test.store.findAll(),conditionSql);
		
		var dataPaginator=getPaginator(data,model.state);
	    
	    var start=sliceStart(dataPaginator);
	    var end=sliceEnd(data,start,dataPaginator);
	    
	    var respData = _.extend({},dataPaginator) ;
	    respData.Items = data.slice(start,end);
	    
	    var resp = {
	    	    code: 0,
			    message: "成功！",
			    data: respData
	    };
	    
		callback(resp);
	},
	
	/*获取Model数据*/
	get:function(model){
		
		var resp={
			code:0,
			message:'',
			data:{}
		};
		
		var data=model.id!=null ? getItemFormLocalStorage(model.id,model.test.store) : model.test.store.findAll();
		
		if(data!=null){
			resp.message='获取数据成功！';
			resp.data=data;
		}else{
			resp.code='-2';
			resp.message='获取数据失败！';
		}
		
		return resp;
	},
	
	/*添加*/
	add:function(model,callback){
		
		var resp={
			code:0,
			message:'',
			data:{}
		};
		resp=this.validate_add(model,resp);
		if(resp.code==0){
			addItemToLocalStorage(model.id,model,model.test.store);
			resp.message='添加成功！';				
		}else{
			resp.code==-3;
		}
		
		return resp;
	},
	
	/*更新*/
	update:function(model,callback){
		
		var resp={
			code:0,
			message:'',
			data:{}
		};
		resp=this.validate_update(model,resp);
		if(resp.code==0){
			updateItemToLocalStorage(model.id,model,model.test.store);
			resp.message='更新成功！';				
		}else{
			resp.code==-3;
		}
		
		return resp;
	},
	
	/*删除*/
	delete:function(model,callback){
		
		var resp={
			code:0,
			message:'',
			data:{}
		};
		resp=this.validate_delete(model,resp);
		if(resp.code==0){
			deleteItemToLocalStorage(model.id,model,model.test.store);
			resp.message='删除成功！';				
		}else{
			resp.code==-3;
		}
		
		return resp;
	},

	/*删除全部*/
	deleteAll:function(model,callback){
		var resp={
			code:0,
			message:'',
			data:{}
		};
		if(resp.code==0){
			deleteToLocalStorage(model.test.store);
			resp.message='删除成功！';				
		}else{
			resp.code==-3;
		}
		
		return resp;
	},
	
	/*添加校验*/
	validate_add:function(model,resp){
		
		/*对象ID重复校验*/
		if(isExistInLocalStorage(model.id,model.test.store)){
			resp.code=-1;
			resp.message='货品ID重复：'+model.id;
			
			return resp;
		}
		
		return resp;
	},
	
	/*更新校验*/
	validate_update:function(model,resp){
		
		return resp;
	},

	/*删除校验*/
	validate_delete:function(model,resp){
		
		return resp;
	}

};